

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="dayu">
  <meta name="keywords" content="">
  
    <meta name="description" content="地区销量排行模块(11.16)2.4.1.代码环境的准备RankPage.vue 12345678910111213141516171819202122&lt;!--针对于 &#x2F;rankpage 这条路径而显示出来的在这个组件中, 通过子组件注册的方式, 要显示出Rank.vue这个组件--&gt;&lt;template&gt;  &lt;div class&#x3D;&quot;com-page&amp;quot">
<meta property="og:type" content="article">
<meta property="og:title" content="数据可视化项目六">
<meta property="og:url" content="http://example.com/2022/11/16/%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96%E9%A1%B9%E7%9B%AE%E5%85%AD/index.html">
<meta property="og:site_name" content="Dayu">
<meta property="og:description" content="地区销量排行模块(11.16)2.4.1.代码环境的准备RankPage.vue 12345678910111213141516171819202122&lt;!--针对于 &#x2F;rankpage 这条路径而显示出来的在这个组件中, 通过子组件注册的方式, 要显示出Rank.vue这个组件--&gt;&lt;template&gt;  &lt;div class&#x3D;&quot;com-page&amp;quot">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-11-16T13:19:33.000Z">
<meta property="article:modified_time" content="2023-09-05T13:21:06.583Z">
<meta property="article:author" content="dayu">
<meta property="article:tag" content="echarts">
<meta name="twitter:card" content="summary_large_image">
  
  
  
  <title>数据可视化项目六 - Dayu</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.3","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 5.4.2"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>dayu</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="数据可视化项目六"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-11-16 21:19" pubdate>
          2022年11月16日 晚上
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          6.2k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          52 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">数据可视化项目六</h1>
            
            
              <div class="markdown-body">
                
                <h1 id="地区销量排行模块-11-16"><a href="#地区销量排行模块-11-16" class="headerlink" title="地区销量排行模块(11.16)"></a>地区销量排行模块(11.16)</h1><h2 id="2-4-1-代码环境的准备"><a href="#2-4-1-代码环境的准备" class="headerlink" title="2.4.1.代码环境的准备"></a>2.4.1.代码环境的准备</h2><p><code>RankPage.vue</code></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><code class="hljs vue">&lt;!--<br>针对于 /rankpage 这条路径而显示出来的<br>在这个组件中, 通过子组件注册的方式, 要显示出Rank.vue这个组件<br>--&gt;<br>&lt;template&gt;<br>  &lt;div class=&quot;com-page&quot;&gt;<br>    &lt;rank&gt;&lt;/rank&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;<br>&lt;script&gt;<br>import Rank from &#x27;@/components/Rank&#x27;<br>export default &#123;<br>  data() &#123;<br>    return &#123;&#125;<br>  &#125;,<br>  methods: &#123;&#125;,<br>  components: &#123;<br>    rank: Rank,<br>  &#125;,<br>&#125;<br>&lt;/script&gt;<br>&lt;style lang=&quot;less&quot; scoped&gt;&lt;/style&gt;<br></code></pre></td></tr></table></figure>

<p><code>Rank.vue</code></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br></pre></td><td class="code"><pre><code class="hljs vue">&lt;!-- 地区销售排行 --&gt;<br>&lt;template&gt;<br>  &lt;div class=&quot;com-container&quot;&gt;<br>    &lt;div class=&quot;com-chart&quot; ref=&quot;rank_ref&quot;&gt;&lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;<br>&lt;script&gt;<br>export default &#123;<br>  data() &#123;<br>    return &#123;<br>      chartInstance: null,<br>      allData: null,<br>    &#125;<br>  &#125;,<br>  mounted() &#123;<br>    this.initChart()<br>    this.getData()<br>    window.addEventListener(&#x27;resize&#x27;, this.screenAdapter)<br>    this.screenAdapter()<br>  &#125;,<br>  destroyed() &#123;<br>    window.removeEventListener(&#x27;resize&#x27;, this.screenAdapter)<br>  &#125;,<br>  methods: &#123;<br>    initChart() &#123;<br>      this.chartInstance = this.$echarts.init(this.$refs.rank_ref)<br>      const initOption = &#123;&#125;<br>      this.chartInstance.setOption(initOption)<br>    &#125;,<br>    async getData() &#123;<br>      // 获取服务器的数据, 对this.allData进行赋值之后, 调用updateChart方法更新图表<br>      this.updateChart()<br>    &#125;,<br>    updateChart() &#123;<br>      // 处理图表需要的数据<br>      const dataOption = &#123;&#125;<br>      this.chartInstance.setOption(dataOption)<br>    &#125;,<br>    screenAdapter() &#123;<br>      const adapterOption = &#123;&#125;<br>      this.chartInstance.setOption(adapterOption)<br>      this.chartInstance.resize()<br>    &#125;,<br>  &#125;,<br>&#125;<br>&lt;/script&gt;<br>&lt;style lang=&quot;less&quot; scoped&gt;&lt;/style&gt;<br></code></pre></td></tr></table></figure>

<p><code>router/index.js</code></p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs json">......<br>import RankPage from &#x27;@/views/RankPage&#x27;<br>......<br>const routes = <span class="hljs-punctuation">[</span><br>	......<br>	<span class="hljs-punctuation">&#123;</span><br>		path<span class="hljs-punctuation">:</span> &#x27;/rankpage&#x27;<span class="hljs-punctuation">,</span><br>		component<span class="hljs-punctuation">:</span> RankPage<br>	<span class="hljs-punctuation">&#125;</span><br><span class="hljs-punctuation">]</span><br>......<br></code></pre></td></tr></table></figure>

<h2 id="2-4-2-图表基本功能的实现"><a href="#2-4-2-图表基本功能的实现" class="headerlink" title="2.4.2.图表基本功能的实现"></a>2.4.2.图表基本功能的实现</h2><ul>
<li><p>数据的获取</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">async</span> getData () &#123;<br>	<span class="hljs-comment">// 获取服务器的数据, 对this.allData进行赋值之后, 调用updateChart方法更新图表</span><br>	<span class="hljs-keyword">const</span> &#123; <span class="hljs-attr">data</span>: ret &#125; = <span class="hljs-keyword">await</span> <span class="hljs-variable language_">this</span>.<span class="hljs-property">$http</span>.<span class="hljs-title function_">get</span>(<span class="hljs-string">&#x27;rank&#x27;</span>)<br>	<span class="hljs-variable language_">this</span>.<span class="hljs-property">allData</span> = ret<br>    <span class="hljs-comment">// 对数据进行排序, 从大到小排序</span><br>	<span class="hljs-variable language_">this</span>.<span class="hljs-property">allData</span>.<span class="hljs-title function_">sort</span>(<span class="hljs-function">(<span class="hljs-params">a, b</span>) =&gt;</span> &#123;<br>	<span class="hljs-keyword">return</span> b.<span class="hljs-property">value</span> - a.<span class="hljs-property">value</span><br>	&#125;)<br>	<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">updateChart</span>()<br>&#125;,<br><br></code></pre></td></tr></table></figure></li>
<li><p>数据的处理</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><code class="hljs js">updateChart () &#123;<br>	<span class="hljs-comment">// 处理图表需要的数据</span><br>	<span class="hljs-keyword">const</span> provinceArr = <span class="hljs-variable language_">this</span>.<span class="hljs-property">allData</span>.<span class="hljs-title function_">map</span>(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> &#123;<br>		<span class="hljs-keyword">return</span> item.<span class="hljs-property">name</span><br>	&#125;)<br>	<span class="hljs-keyword">const</span> valueArr = <span class="hljs-variable language_">this</span>.<span class="hljs-property">allData</span>.<span class="hljs-title function_">map</span>(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> &#123;<br>		<span class="hljs-keyword">return</span> item.<span class="hljs-property">value</span><br>	&#125;)<br>	<span class="hljs-keyword">const</span> dataOption = &#123;<br>		<span class="hljs-attr">xAxis</span>: &#123;<br>			<span class="hljs-attr">data</span>: provinceArr<br>		&#125;,<br>		<span class="hljs-attr">series</span>: [<br>			&#123;<br>				<span class="hljs-attr">data</span>: valueArr<br>			&#125;<br>		]<br>	&#125;<br>	<span class="hljs-variable language_">this</span>.<span class="hljs-property">chartInstance</span>.<span class="hljs-title function_">setOption</span>(dataOption)<br>&#125;,<br></code></pre></td></tr></table></figure></li>
<li><p>初始化配置</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><code class="hljs js">initChart () &#123;<br>	<span class="hljs-variable language_">this</span>.<span class="hljs-property">chartInstance</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">$echarts</span>.<span class="hljs-title function_">init</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">$refs</span>.<span class="hljs-property">rank_ref</span>)<br>	<span class="hljs-keyword">const</span> initOption = &#123;<br>		<span class="hljs-attr">xAxis</span>: &#123;<br>			<span class="hljs-attr">type</span>: <span class="hljs-string">&#x27;category&#x27;</span><br>		&#125;,<br>		<span class="hljs-attr">yAxis</span>: &#123;<br>			<span class="hljs-attr">type</span>: <span class="hljs-string">&#x27;value&#x27;</span><br>		&#125;,<br>		<span class="hljs-attr">series</span>: [<br>			&#123;<br>				<span class="hljs-attr">type</span>: <span class="hljs-string">&#x27;bar&#x27;</span><br>			&#125;<br>		]<br>	&#125;<br>	<span class="hljs-variable language_">this</span>.<span class="hljs-property">chartInstance</span>.<span class="hljs-title function_">setOption</span>(initOption)<br>&#125;<br></code></pre></td></tr></table></figure></li>
</ul>
<h2 id="2-4-3-UI-效果调整"><a href="#2-4-3-UI-效果调整" class="headerlink" title="2.4.3. UI 效果调整"></a>2.4.3. UI 效果调整</h2><ul>
<li><p>主题的使用</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs js">initChart () &#123;<br>	<span class="hljs-variable language_">this</span>.<span class="hljs-property">chartInstance</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">$echarts</span>.<span class="hljs-title function_">init</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">$refs</span>.<span class="hljs-property">rank_ref</span>, <span class="hljs-string">&#x27;chalk&#x27;</span>)<br>&#125;<br></code></pre></td></tr></table></figure></li>
<li><p>标题的设置</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs js">initChart () &#123;<br>	<span class="hljs-variable language_">this</span>.<span class="hljs-property">chartInstance</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">$echarts</span>.<span class="hljs-title function_">init</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">$refs</span>.<span class="hljs-property">rank_ref</span>, <span class="hljs-string">&#x27;chalk&#x27;</span>)<br>	<span class="hljs-keyword">const</span> initOption = &#123;<br>		<span class="hljs-attr">title</span>: &#123;<br>			<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;▎ 地区销售排行&#x27;</span>,<br>			<span class="hljs-attr">left</span>: <span class="hljs-number">20</span>,<br>			<span class="hljs-attr">top</span>: <span class="hljs-number">20</span><br>		&#125;<br></code></pre></td></tr></table></figure></li>
<li><p>坐标轴大小和位置</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs js">initChart () &#123;<br>	<span class="hljs-variable language_">this</span>.<span class="hljs-property">chartInstance</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">$echarts</span>.<span class="hljs-title function_">init</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">$refs</span>.<span class="hljs-property">rank_ref</span>, <span class="hljs-string">&#x27;chalk&#x27;</span>)<br>	<span class="hljs-keyword">const</span> initOption = &#123;<br>		......<br>		<span class="hljs-attr">grid</span>: &#123;<br>			<span class="hljs-attr">top</span>: <span class="hljs-string">&#x27;40%&#x27;</span>,<br>			<span class="hljs-attr">left</span>: <span class="hljs-string">&#x27;5%&#x27;</span>,<br>			<span class="hljs-attr">bottom</span>: <span class="hljs-string">&#x27;5%&#x27;</span>,<br>			<span class="hljs-attr">right</span>: <span class="hljs-string">&#x27;5%&#x27;</span>,<br>			<span class="hljs-attr">containLabel</span>: <span class="hljs-literal">true</span><br>		&#125;<br></code></pre></td></tr></table></figure></li>
<li><p>工具提示</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-attr">tooltip</span>: &#123;<br>  <span class="hljs-attr">show</span>: <span class="hljs-literal">true</span><br>&#125;<br></code></pre></td></tr></table></figure></li>
<li><p>颜色的设置</p>
<ul>
<li>不同柱显示不同颜色</li>
<li>渐变的控制</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><code class="hljs js">updateChart () &#123;<br>	<span class="hljs-comment">// 处理图表需要的数据</span><br>	<span class="hljs-keyword">const</span> colorArr = [<br>        [<span class="hljs-string">&#x27;#0BA82C&#x27;</span>, <span class="hljs-string">&#x27;#4FF778&#x27;</span>],<br>        [<span class="hljs-string">&#x27;#2E72BF&#x27;</span>, <span class="hljs-string">&#x27;#23E5E5&#x27;</span>],<br>        [<span class="hljs-string">&#x27;#5052EE&#x27;</span>, <span class="hljs-string">&#x27;#AB6EE5&#x27;</span>]<br>	]<br>	......<br>	<span class="hljs-keyword">const</span> dataOption = &#123;<br>		<span class="hljs-attr">xAxis</span>: &#123;<br>			<span class="hljs-attr">data</span>: provinceArr<br>		&#125;,<br>		<span class="hljs-attr">series</span>: [<br>			&#123;<br>				<span class="hljs-attr">data</span>: valueArr,<br>				<span class="hljs-attr">itemStyle</span>: &#123;<br>					<span class="hljs-attr">color</span>: <span class="hljs-function"><span class="hljs-params">arg</span> =&gt;</span> &#123;<br>                        <span class="hljs-keyword">let</span> targetColorArr = colorArr[<span class="hljs-number">0</span>]<br>                        <span class="hljs-keyword">if</span> (arg.<span class="hljs-property">vaule</span> &gt;= <span class="hljs-number">300</span>) &#123;<br>							targetColorArr = colorArr[<span class="hljs-number">0</span>]<br>						&#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (arg.<span class="hljs-property">value</span> &gt;= <span class="hljs-number">200</span>) &#123;<br>							targetColorArr = colorArr[<span class="hljs-number">1</span>]<br>						&#125; <span class="hljs-keyword">else</span> &#123;<br>							targetColorArr = colorArr[<span class="hljs-number">2</span>]<br>						&#125;<br>						<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-variable language_">this</span>.<span class="hljs-property">$echarts</span>.<span class="hljs-property">graphic</span>.<span class="hljs-title class_">LinearGradient</span>(<span class="hljs-number">0</span>,<br><span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, [<br>							&#123;<br>								<span class="hljs-attr">offset</span>: <span class="hljs-number">0</span>,<br>								<span class="hljs-attr">color</span>: targetColorArr[<span class="hljs-number">0</span>]<br>							&#125;,<br>							&#123;<br>                                <span class="hljs-attr">offset</span>: <span class="hljs-number">1</span>,<br>                                <span class="hljs-attr">color</span>: targetColorArr[<span class="hljs-number">1</span>]<br>							&#125;<br>						])<br>					&#125;<br>				&#125;<br>			&#125;<br>		]<br>	&#125;<br>	<span class="hljs-variable language_">this</span>.<span class="hljs-property">chartInstance</span>.<span class="hljs-title function_">setOption</span>(dataOption)<br>&#125;,<br></code></pre></td></tr></table></figure></li>
</ul>
<h2 id="2-4-4-平移动画的实现"><a href="#2-4-4-平移动画的实现" class="headerlink" title="2.4.4.平移动画的实现"></a>2.4.4.平移动画的实现</h2><p>平移动画可以使用 <code>dataZoom </code>中的 <code>startValue </code>和<code>endValue</code>来实现</p>
<ul>
<li><p>定义数据</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs js">data () &#123;<br>	<span class="hljs-keyword">return</span> &#123;<br>        <span class="hljs-attr">chartInstance</span>: <span class="hljs-literal">null</span>,<br>        <span class="hljs-attr">allData</span>: <span class="hljs-literal">null</span>,<br>        <span class="hljs-attr">startValue</span>: <span class="hljs-number">0</span>,<br>        <span class="hljs-attr">endValue</span>: <span class="hljs-number">9</span><br>	&#125;<br>&#125;<br></code></pre></td></tr></table></figure></li>
<li><p>将 <code>startValue</code> 和 <code>endValue </code>应用在 <code>dataZoom</code> 上, 并隐藏 <code>dataZoom</code> 的显示</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs js">updateChart () &#123;<br>	......<br>	<span class="hljs-keyword">const</span> dataOption = &#123;<br>		<span class="hljs-attr">xAxis</span>: &#123;<br>			<span class="hljs-attr">data</span>: provinceArr<br>		&#125;,<br>		<span class="hljs-attr">dataZoom</span>: &#123;<br>			<span class="hljs-attr">show</span>: <span class="hljs-literal">false</span>,<br>            <span class="hljs-attr">startValue</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">startValue</span>,<br>            <span class="hljs-attr">endValue</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">endValue</span><br>		&#125;,<br></code></pre></td></tr></table></figure></li>
<li><p>启动和停止定时器</p>
<p>增加<code>timerId</code>的变量, 并且增加一个方法 <code>startInterval</code> ,来控制 <code>startValue</code> 和 <code>endValue </code>的值</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><code class="hljs js">&lt;script&gt;<br><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> &#123;<br>	data () &#123;<br>		<span class="hljs-keyword">return</span> &#123;<br>            <span class="hljs-attr">chartInstance</span>: <span class="hljs-literal">null</span>,<br>            <span class="hljs-attr">allData</span>: <span class="hljs-literal">null</span>,<br>            <span class="hljs-attr">startValue</span>: <span class="hljs-number">0</span>,<br>            <span class="hljs-attr">endValue</span>: <span class="hljs-number">9</span>,<br>            <span class="hljs-attr">timerId</span>: <span class="hljs-literal">null</span><br>		&#125;<br>	&#125;,<br>......<br>	<span class="hljs-attr">methods</span>: &#123;<br>		......<br>		startInterval () &#123;<br>			<span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">timerId</span>) &#123;<br>				<span class="hljs-built_in">clearInterval</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">timerId</span>)<br>			&#125;<br>			<span class="hljs-variable language_">this</span>.<span class="hljs-property">timerId</span> = <span class="hljs-built_in">setInterval</span>(<span class="hljs-function">() =&gt;</span> &#123;<br>				<span class="hljs-variable language_">this</span>.<span class="hljs-property">startValue</span>++<br>				<span class="hljs-variable language_">this</span>.<span class="hljs-property">endValue</span>++<br>				<span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">endValue</span> &gt; <span class="hljs-variable language_">this</span>.<span class="hljs-property">allData</span>.<span class="hljs-property">length</span> - <span class="hljs-number">1</span>) &#123;<br>                    <span class="hljs-variable language_">this</span>.<span class="hljs-property">startValue</span> = <span class="hljs-number">0</span><br>                    <span class="hljs-variable language_">this</span>.<span class="hljs-property">endValue</span> = <span class="hljs-number">9</span><br>				&#125;<br>				<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">updateChart</span>()<br>			&#125;, <span class="hljs-number">3000</span>)<br>		&#125;<br>	&#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<ul>
<li><p>获取数据之后启动</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">async</span> getData () &#123;<br>	......<br>	<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">updateChart</span>()<br>	<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">startInterval</span>()<br>&#125;,<br></code></pre></td></tr></table></figure></li>
<li><p>组件销毁停止</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs js">destroyed () &#123;<br>	<span class="hljs-variable language_">window</span>.<span class="hljs-title function_">removeEventListener</span>(<span class="hljs-string">&#x27;resize&#x27;</span>, <span class="hljs-variable language_">this</span>.<span class="hljs-property">screenAdapter</span>)<br>	<span class="hljs-built_in">clearInterval</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">timerId</span>)<br>&#125;,<br></code></pre></td></tr></table></figure></li>
<li><p>鼠标移入停止</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-attr">methods</span>: &#123;<br>	initChart () &#123;<br>		......<br>		<span class="hljs-variable language_">this</span>.<span class="hljs-property">chartInstance</span>.<span class="hljs-title function_">setOption</span>(initOption)<br>		<span class="hljs-variable language_">this</span>.<span class="hljs-property">chartInstance</span>.<span class="hljs-title function_">on</span>(<span class="hljs-string">&#x27;mouseover&#x27;</span>, <span class="hljs-function">() =&gt;</span> &#123;<br>			<span class="hljs-built_in">clearInterval</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">timerId</span>)<br>		&#125;)<br></code></pre></td></tr></table></figure></li>
<li><p>鼠标离开启动</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-attr">methods</span>: &#123;<br>	initChart () &#123;<br>		......<br>		<span class="hljs-variable language_">this</span>.<span class="hljs-property">chartInstance</span>.<span class="hljs-title function_">on</span>(<span class="hljs-string">&#x27;mouseout&#x27;</span>, <span class="hljs-function">() =&gt;</span> &#123;<br>		<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">startInterval</span>()<br>	&#125;)<br>&#125;,<br></code></pre></td></tr></table></figure></li>
</ul>
</li>
</ul>
<h2 id="2-4-5-分辨率适配"><a href="#2-4-5-分辨率适配" class="headerlink" title="2.4.5.分辨率适配"></a>2.4.5.分辨率适配</h2><ul>
<li><p>计算 <code>titleFontSize</code></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs js">screenAdapter () &#123;<br>	<span class="hljs-keyword">const</span> titleFontSize = <span class="hljs-variable language_">this</span>.<span class="hljs-property">$refs</span>.<span class="hljs-property">rank_ref</span>.<span class="hljs-property">offsetWidth</span> / <span class="hljs-number">100</span> * <span class="hljs-number">3.6</span><br>&#125;<br></code></pre></td></tr></table></figure></li>
<li><p>将 <code>titleFontSize </code>设置给图表的某些区域</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><code class="hljs js">screenAdapter () &#123;<br>	<span class="hljs-keyword">const</span> titleFontSize = <span class="hljs-variable language_">this</span>.<span class="hljs-property">$refs</span>.<span class="hljs-property">rank_ref</span>.<span class="hljs-property">offsetWidth</span> / <span class="hljs-number">100</span> * <span class="hljs-number">3.6</span><br>	<span class="hljs-keyword">const</span> adapterOption = &#123;<br>		<span class="hljs-attr">title</span>: &#123;<br>			<span class="hljs-attr">textStyle</span>: &#123;<br>				<span class="hljs-attr">fontSize</span>: titleFontSize<br>			&#125;<br>		&#125;,<br>		<span class="hljs-attr">series</span>: [<br>			&#123;<br>				<span class="hljs-attr">barWidth</span>: titleFontSize,<br>				<span class="hljs-attr">itemStyle</span>: &#123;<br>					<span class="hljs-attr">barBorderRadius</span>: [<span class="hljs-number">0.5</span> * titleFontSize, <span class="hljs-number">0.5</span> *<br>titleFontSize, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]<br>				&#125;<br>			&#125;<br>		]<br>	&#125;<br>	<span class="hljs-variable language_">this</span>.<span class="hljs-property">chartInstance</span>.<span class="hljs-title function_">setOption</span>(adapterOption)<br>	<span class="hljs-variable language_">this</span>.<span class="hljs-property">chartInstance</span>.<span class="hljs-title function_">resize</span>()<br>&#125;,<br></code></pre></td></tr></table></figure></li>
</ul>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96%E9%A1%B9%E7%9B%AE/" class="category-chain-item">数据可视化项目</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/echarts/">#echarts</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>数据可视化项目六</div>
      <div>http://example.com/2022/11/16/数据可视化项目六/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>dayu</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年11月16日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/11/16/%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96%E9%A1%B9%E7%9B%AE%E4%BA%94/" title="数据可视化项目五">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">数据可视化项目五</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2022/11/16/%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96%E9%A1%B9%E7%9B%AE%E4%BA%8C/" title="数据可视化项目二">
                        <span class="hidden-mobile">数据可视化项目二</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
